import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import getters from './getters'
import mutations from './mutations'
import actions from './actions'
Vue.use(Vuex)

const Store = new Vuex.Store({
  state,
  getters,
  mutations,
  actions
})

export default Store;

// 初始化数据--应当把state里面的都挪过来
(() => {
  let lang = localStorage.getItem('language')
  if (!lang) {
    lang = (navigator.language || navigator.languages[0]).slice(0, 2)
  }
  Store.commit('updataLanguage', lang)
})()
